//============================================================================
// Name        : boundary.cpp
// Author      : dfoelber
//============================================================================

// INCLUDES //
#include "physics/boundary.h"
#include <iostream>
//////////////

using namespace std;

/**
* Constructor
**/
Boundary::Boundary()
{	
}

/**
* Destructor
**/
Boundary::~Boundary()
{
}

/**
* Sets the boundary as a rectangle.
* 
* @param x The new X coordinate
* @param y The new Y coordinate
* @param width The new width
* @param height The new height
**/
void Boundary::SetBoundary( int x, int y, int width, int height )
{
	this->x = x;
	this->y = y;
	this->width = width;
	this->height = height;
}

/**
* Gets the X coordinate
* 
* @return The current X coordinate
**/
int Boundary::GetX()
{
	return x;
}

/**
* Gets the Y coordinate
* 
* @return The current Y coordinate
**/
int Boundary::GetY()
{
	return y;
}

/**
* Gets the width
* 
* @return The current width
**/	
int Boundary::GetWidth()
{
	return width;
}

/**
* Gets the height
* 
* @return The current height
**/	
int Boundary::GetHeight()
{
	return height;
}

/**
* Checks the given area and makes sure that it is
* within the boundary. Notifies path on intersection.
* 
* @param path The path to check for intersection
* @return true if the area intersects the boundary.
**/
bool Boundary::Check( Path* path )
{
	bool moved = false;
	/*if( path->GetX() + path->GetXDistance() < x ) // intersected at the left side
    {
    	Area boundary;
    	boundary.SetPosition( x - 1, y );
    	boundary.SetSize( 1, height );
    	path->Collision( Path::SIDE_LEFT, &boundary );
    	moved = true;
    }
    if( path->GetX() + path->GetWidth() + path->GetXDistance() > x + width ) // intersected at the right side
    {
    	Area boundary;
    	boundary.SetPosition( x + width, y );
    	boundary.SetSize( 1, height );
    	path->Collision( Path::SIDE_RIGHT, &boundary );
    	moved = true;
    }
    if( path->GetY() + path->GetYDistance() < y ) // intersected at the top side
    {
    	Area boundary;
    	boundary.SetPosition( x, y - 1 );
    	boundary.SetSize( width, 1 );
    	path->Collision( Path::SIDE_TOP, &boundary );
    	moved = true;
    }
    if( path->GetY() + path->GetYDistance() + path->GetHeight() > y + height ) // intersected at the bottom side
    {
    	Area boundary;
    	boundary.SetPosition( x, y + height );
    	boundary.SetSize( width, 1 );
    	path->Collision( Path::SIDE_BOTTOM, &boundary );
    	moved = true;
    }
    */
    return moved;
}
